import time
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from  selenium.webdriver.support.ui import WebDriverWait
from Page import Page
from Page1 import Page1
from Page2 import Page2
from  ddt import file_data,ddt

@ddt
class TestCase(unittest.TestCase):
    def setUp(self):
       self.driver=webdriver.Edge()
       self.driver.maximize_window()

    def tearDown(self):
        time.sleep(3)
        self.driver.quit()

    @file_data('yaml.yaml')
    def test_01_sou(self,username,password):
        po=Page(self.driver)
        po.open_url('http://localhost:8080/yklogin3')
        po.username(username)
        po.password(password)
        po.login()
        po.que()
        time.sleep(5)
        duan=self.driver.find_element(By.XPATH,'/html/body/div[1]/div/section/section/main/div[1]/form/div[2]/div[1]/div/div/button').text
        self.assertEqual(duan,'搜索')
        print(duan)
        time.sleep(2)
        po.shu()
        po.sou()

    def test_02_add(self):
        po=Page1(self.driver)
        po.luoji_add()
    def test_03_del(self):
        po = Page2(self.driver)
        po.luoji_del()
if __name__ == '__main__':
    unittest.main()
